package com.itheima.HomeWork_day08;
/*
List集合的特有方法:
 */
import java.util.ArrayList;

public class ListTest03 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("www");
        list.add("yyy");
        list.add("mmm");
        list.add("sss");

        System.out.println(list);

        //void add(int index,E   element)在此集合中的指定位置插入指定的元素E

        addList(list);

        // remove(int   index)删除指定索引处的元素，返回被删除的元素E
        removeList(list);

        // set(int index,E   element)修改指定索引处的元素，返回被修改的元素E
        setList(list);

        // get(int   index)返回指定索引处的元素
        getList(list);

    }

    private static void getList(ArrayList<String> list) {
        String s = list.get(3);
        System.out.println(s);
    }

    private static void setList(ArrayList<String> list) {
        String set = list.set(3, "ggg");
        System.out.println(set);
        System.out.println(list);
    }

    private static void removeList(ArrayList<String> list) {
        String remove = list.remove(0);
        System.out.println(remove);
        System.out.println(list);
    }

    private static void addList(ArrayList<String> list) {
        list.add(2, "kkk");
        System.out.println(list);
    }
}
